package admin

import (
	database "hft/Database"
	"hft/Database/admin/loupan_db"
)

type LouPan struct {
	database.Base
	// LouPanName       LouPanName      `json:"-" gorm:"-"`
	Name             string                `json:"name,omitempty" gorm:"uniqueIndex:region_name"`
	Cover            string                `json:"cover,omitempty"`
	RegionLink       string                `json:"regionLink,omitempty" gorm:"index"`
	Region           int                   `json:"region,omitempty" gorm:"uniqueIndex:region_name"`
	BelongName       string                `json:"belongName,omitempty" gorm:"comment:所属区域;index"`
	FirstWord        string                `json:"firstWord"`
	ReferencePrice   int                   `json:"reference_price" gorm:"column:reference_price;type:int;comment:参考价;default:0"`
	MaxArea          int                   `json:"maxArea"`
	MinArea          int                   `json:"minArea"`
	MaxPrice         int                   `json:"max_price"` //最大价格
	MinPrice         int                   `json:"min_price"` //最小价格
	Years            string                `json:"years,omitempty" gorm:"column:years;comment:产权年限"`
	Grounding        int                   `json:"grounding" gorm:"column:grounding;type:tinyint(1);comment:是否上架"`
	Address          string                `json:"address,omitempty" gorm:"column:address;type:varchar(255);size:255;comment:详细地址;index"`
	Longitude        float64               `json:"longitude" gorm:"index"`
	Latitude         float64               `json:"latitude" gorm:"index"`
	Furnish          string                `json:"furnish,omitempty"`
	IsAudit          int                   `json:"isAudit"`
	Status           int                   `json:"sell_status" gorm:"comment:销售状态"`
	ActiveLastUpdate int                   `json:"activeLastUpdate"` //动态最后更新时间
	Accounts         []*Account            `json:"accounts,omitempty" gorm:"many2many:_account_lou_pan;foreignKey:ID;references:ID;constraint:OnDelete:CASCADE;OnUpdate:NO ACTION"`
	Activities       []*Activity           `json:"activities" gorm:"foreignKey:LouPanId;references:ID;constraint:OnDelete:CASCADE"`
	LouPanSwiper     []*LouPanSwiper       `json:"swiper,omitempty" gorm:"foreignKey:LouPanID;references:ID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	LouPanArea       LouPanArea            `json:"lou_pan_area,omitempty" gorm:"foreignKey:LouPanId;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	SellLouPanInfo   SellLouPanInfo        `json:"sellLouPanInfo,omitempty" gorm:"foreignKey:LouPanId;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	SellStatus       SellStatus            `json:"sellStatus,omitempty" gorm:"foreignKey:StatusCode;references:Status;constraint:OnDelete:NO ACTION,OnUpdate:CASCADE"`
	Properties       []*Property           `json:"property" gorm:"many2many:_loupan_property;foreignKey:ID;references:StatusCode;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	Tags             []*CommonTag          `json:"tags" gorm:"many2many:_loupan_tag;foreignKey:ID;references:ID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	TeSe             []*LouPanTeSe         `json:"tese" gorm:"many2many:_loupan_tese;foreignKey:ID;references:Name;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	RoomType         []*RoomType           `json:"room_type" gorm:"many2many:_loupan_room_type;foreignKey:ID;references:ID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	Disadvantage     []*Disadvantage       `json:"disadvantage" gorm:"many2many:_loupan_disadvantage;foreignKey:ID;references:ID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
	PlatForm         []*loupan_db.Platform `json:"plat_form" gorm:"foreignKey:LouPanID;references:ID;constraint:OnDelete:CASCADE"`
}

func (LouPan) TableName() string {
	return database.TableNameFormat("loupans")
}
